<template>
	<view class="content">
		<view class="header">
			<view class="userinfo" @click="goInfo" >
				<image class="head" :src="personalList.avatar" v-if="personalList.avatar"></image>
				<image class="head" src="/static/head_default.png" v-else></image>
				<view class="name">{{personalList.realname?personalList.realname : personalList.username}}</view>
					<view class="info">{{ personalList.phone }}</view>
			</view>
			<uni-icons @click="goSetting" type="gear" size="30" color="white"
				style="position: absolute;top: 10px;right: 10px;" v-if="userId"></uni-icons>
		</view>
		<view class="flex-wrap func-wrap br" v-if="userInfo?.id">
			<view class="flex-item">
				<view class="top-menu-item">
					<uni-icons type="auth-filled" size="35" color="#f95249"></uni-icons>
					<view class="name">待使用/发货</view>
				</view>
			</view>
			<view class="flex-item">
				<view class="top-menu-item" >
					<uni-icons type="paperplane-filled" size="35" color="#f95249"></uni-icons>
					<view class="name">待收货</view>
				</view>
			</view>
			<view class="flex-item">
				<view class="top-menu-item">
					<uni-icons type="staff-filled" size="35" color="#f95249"></uni-icons>
					<view class="name">待评价</view>
				</view>
			</view>
			<view class="flex-item">
				<view class="top-menu-item">
					<uni-icons type="location-filled" size="35" color="#f95249"></uni-icons>
					<view class="name">收货地址</view>
				</view>
			</view>
		</view>
			
		
		<view class="p-menu">
			<view class="p-menu-title more p20">
				我的消息
				<view class="more-info"
>					供餐日历已发布
					<svg-icon name="right" size="26rpx" color="#c0c0c0" />
				</view>
			</view>
		</view>
		
		<view class="p-menu">
			<view class="p-menu-title">我的信息</view>
			<view class="menu">
				<view class="line">
					<view class="menu-item">
						<uni-icons type="person" :size="30" color="#333" class="menu-icon menu-icon-bg2"/>
						<view class="text">学生管理</view>
					</view>
					<view class="menu-item">
						<svg-icon name="folder" :size="30" color="#333"/>
						<view class="text">常用信息</view>
					</view>
					<view class="menu-item">
						<svg-icon name="point" :size="30" color="#333"/>
						<view class="text">我的积分</view>
					</view>
					<view class="menu-item">
						<svg-icon name="bill" :size="30" color="#333"/>
						<view class="text">我的账单</view>
					</view>
				</view>
			</view>
		</view>
		
	  <view class="p-menu">
			<view class="p-menu-title">更多服务</view>
			<view class="menu">
				<view class="line">
					<view class="menu-item">
						<svg-icon name="card" :size="30" color="#333"/>
						<view class="text">我的卡券</view>
					</view>
					<view class="menu-item">
						<svg-icon name="pastDue" :size="30" color="#333"/>
						<view class="text">欠费账单</view>
					</view>
					<view class="menu-item">
						<svg-icon name="defend" :size="30" color="#333"/>
						<view class="text">申请维权</view>
					</view>
					<view class="menu-item">
						<svg-icon name="guest" :size="30" color="#333"/>
						<view class="text">联系平台</view>
					</view>
				</view>
				<view class="line">
					<view class="menu-item">
						<svg-icon name="comment" :size="30" color="#333"/>
						<view class="text">我的评论</view>
					</view>
					<view class="menu-item">
						<svg-icon name="watch" :size="30" color="#333"/>
						<view class="text">我的关注</view>
					</view>
					<view class="menu-item">
						<svg-icon name="collect" :size="30" color="#333"/>
						<view class="text">我的收藏</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				personalList:{
				  avatar:'',
				  realname:'',
				  username:'',
				  post:'',
				  depart:'',
					phone: ''
				},
				userId: undefined
			}
		},
		onShow:function(){
			this.load();
		},
		onPullDownRefresh() {
			this.load();
		},
		methods: {
			getDefaultValue(val){
				return val ? val : '未设置';
			},
			goPage(url){
				uni.navigateTo({
					url: url
				});
			},
			goSetting() {
				this.goPage('/pages/profile/setting/setting');
			},
			goInfo(){
				this.goPage('/pages/profile/edit/edit');
			},
			goLogin(){
				this.goPage('/pages/profile/login/login');
			},
			load() {
				// this.userId = this.userInfo.id
				// if(this.userInfo.avatar){
				// 	this.personalList.avatar = this.userInfo.avatar;
				// }else{
				// 	if(this.userInfo.sex){
				// 		this.personalList.avatar = (this.userInfo.sex==1) ? '/static/avatar_boy.png' :'/static/avatar_girl.png';
				// 	}else{
				// 		this.personalList.avatar = '/static/avatar_girl.png';
				// 	}
				// }
				// this.personalList.realname = this.userInfo.realname;
				// this.personalList.username = this.userInfo.username;
				// this.personalList.depart = this.userInfo.departText
				// this.personalList.post = this.userInfo.postText
				// this.personalList.phone = this.userInfo.phone
				// uni.stopPullDownRefresh();
			},
		}
	}
</script>

<style lang="scss" scoped>
	body {
		background-color: #f1f1f1;
	}
	.func-wrap{
		margin-top: -80rpx;
		text-align: center;
		padding: 28rpx 0;
		width: calc(100% - 48rpx);
		background-color: #fff;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.p-menu-title{
			padding-bottom: 12rpx;
		}
		.top-menu-item {
			padding:10rpx 6rpx;
			.name {
				font-size: 26rpx;
			}
		}

		.header {
			background: linear-gradient(to bottom, #f95249, #f6f6f6 );
			width: 100%;
			height: 200px;
			color: white;

			.userinfo {
				margin-top: 100rpx;
				margin-left: 20rpx;

				.name {
					margin-left: 180rpx;
					font-size: 34rpx;
					padding-top: 30rpx;
				}

				.info {
					margin-left: 180rpx;
					font-size: 24rpx;
					margin-top: 16rpx;
				}

				.head {
					width: 140rpx;
					height: 140rpx;
					border-radius: 140rpx;
					float: left;
					border: 10rpx solid rgba(220, 220, 255, 0.2);
				}
			}
		}
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.nav{
		margin: 30rpx 0;
		width: calc(100vw - 40rpx);
		display: flex;
		flex-wrap: wrap;
		flex-direction: row;
		align-content: space-between;
		justify-content: space-between;
		.nav-item{
			flex: 0 0 49%;
			text-align: left;
			font-size: 24rpx;
			padding: 36rpx 0;
			border-radius: 10rpx;
			.nav-btn{
				float: right;
				margin-right: 20rpx;
				border-radius: 30rpx;
				padding: 10rpx 20rpx;
			}
			.nav-num{
				margin-left: 40rpx;
				font-size: 40rpx;
				font-weight: bold;
				margin-top: -2rpx;
				.nav-u{
					font-size: 28rpx;
					margin-left: 10rpx;
					font-weight: normal;
				}
			}
		}
		.nav-item:nth-child(odd){
			background-color: #DDE3FB;
			.nav-btn{
				background-color: #B8C1FA;
				color: #595D9E;
				font-weight: bold;
			}
			.nav-num{
				color: #595D9E;
			}
		}
		.nav-item:nth-child(even){
			background-color: #CFF3EF;
			.nav-btn{
				background-color: #8CD7DA;
				color: #3C7473;
				font-weight: bold;
			}
			.nav-num{
				color: #3C7473;
			}
		}
	}
	.p-menu-title{
		font-size: 34rpx;
		font-weight: 600;
		color: #222;
		text-align: left;
		margin: 20rpx 0 0; 
		padding-left: 20rpx;
		&.p20{
			margin: 0;
			padding: 24rpx 20rpx;
		}
		&.more{
			.more-info{
				margin-top: 4rpx;
				float: right;
				font-size: 24rpx;
				color: #c0c0c0;
				font-weight: normal;
			}
			.svg-icon{
				vertical-align: -4rpx;
			}
		}
	}
	.p-menu{
		width: calc(100vw - 40rpx);
		margin: 24rpx 20rpx;
		text-align: left;
		background-color: white;
		border-radius: 10rpx;
		
		.menu{
			border-radius: 10rpx;
			overflow: hidden;
			position: relative;
			padding-top: 20rpx;
			.line{
				display: flex;
				flex-wrap: wrap;
				margin-bottom: 40rpx;
				.menu-item{
					flex: 0 0 25%;
					text-align: center;
					font-size: 24rpx;
					padding: 10rpx 0;
					color: #666;
					.menu-icon{
						padding: 8rpx;
						border-radius: 30rpx;
					}
					.text{
						margin-top: 10rpx;
					}
				}
			}
		}
	}
</style>